from django.http import JsonResponse
from rest_framework_simplejwt.serializers import TokenObtainPairSerializer
from rest_framework_simplejwt.views import TokenObtainPairView
# 加密
# from job.EncryptionAndDecryption import aesEncrypt
# 解密
from job.EncryptionAndDecryption import aesDecrypt


class MyTokenObtainPairSerializer(TokenObtainPairSerializer):
    def validate(self, attrs):
        attrs['password'] = aesDecrypt('eSEdSfdED==WGDHa',attrs['password'])
        data =  super().validate(attrs)
        data['accessToken'] = data['access']
        data['status'] = 200
        del data['access']

        return data

class MyTokenObtainPairView(TokenObtainPairView):
    serializer_class =MyTokenObtainPairSerializer